// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.
#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]

/// Implements a client for the App Hub API.
///
/// # Example
/// ```
/// # tokio_test::block_on(async {
/// # use google_cloud_apphub_v1::client::AppHub;
/// let client = AppHub::builder().build().await?;
/// // use `client` to make requests to the App Hub API.
/// # gax::client_builder::Result::<()>::Ok(()) });
/// ```
///
/// # Service Description
///
/// The App Hub API allows you to manage App Hub resources.
///
/// # Configuration
///
/// To configure `AppHub` use the `with_*` methods in the type returned
/// by [builder()][AppHub::builder]. The default configuration should
/// work for most applications. Common configuration changes include
///
/// * [with_endpoint()]: by default this client uses the global default endpoint
///   (`https://apphub.googleapis.com`). Applications using regional
///   endpoints or running in restricted networks (e.g. a network configured
//    with [Private Google Access with VPC Service Controls]) may want to
///   override this default.
/// * [with_credentials()]: by default this client uses
///   [Application Default Credentials]. Applications using custom
///   authentication may need to override this default.
///
/// [with_endpoint()]: super::builder::app_hub::ClientBuilder::with_endpoint
/// [with_credentials()]: super::builder::app_hub::ClientBuilder::credentials
/// [Private Google Access with VPC Service Controls]: https://cloud.google.com/vpc-service-controls/docs/private-connectivity
/// [Application Default Credentials]: https://cloud.google.com/docs/authentication#adc
///
/// # Pooling and Cloning
///
/// `AppHub` holds a connection pool internally, it is advised to
/// create one and the reuse it.  You do not need to wrap `AppHub` in
/// an [Rc](std::rc::Rc) or [Arc](std::sync::Arc) to reuse it, because it
/// already uses an `Arc` internally.
#[derive(Clone, Debug)]
pub struct AppHub {
    inner: std::sync::Arc<dyn super::stub::dynamic::AppHub>,
}

impl AppHub {
    /// Returns a builder for [AppHub].
    ///
    /// ```
    /// # tokio_test::block_on(async {
    /// # use google_cloud_apphub_v1::client::AppHub;
    /// let client = AppHub::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> super::builder::app_hub::ClientBuilder {
        gax::client_builder::internal::new_builder(super::builder::app_hub::client::Factory)
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: super::stub::AppHub + 'static,
    {
        Self {
            inner: std::sync::Arc::new(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let inner = Self::build_inner(config).await?;
        Ok(Self { inner })
    }

    async fn build_inner(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<std::sync::Arc<dyn super::stub::dynamic::AppHub>> {
        if gaxi::options::tracing_enabled(&conf) {
            return Ok(std::sync::Arc::new(Self::build_with_tracing(conf).await?));
        }
        Ok(std::sync::Arc::new(Self::build_transport(conf).await?))
    }

    async fn build_transport(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AppHub> {
        super::transport::AppHub::new(conf).await
    }

    async fn build_with_tracing(
        conf: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<impl super::stub::AppHub> {
        Self::build_transport(conf)
            .await
            .map(super::tracing::AppHub::new)
    }

    /// Lists a service project attachment for a given service project. You can
    /// call this API from any project to find if it is attached to a host project.
    pub fn lookup_service_project_attachment(
        &self,
    ) -> super::builder::app_hub::LookupServiceProjectAttachment {
        super::builder::app_hub::LookupServiceProjectAttachment::new(self.inner.clone())
    }

    /// Lists service projects attached to the host project.
    pub fn list_service_project_attachments(
        &self,
    ) -> super::builder::app_hub::ListServiceProjectAttachments {
        super::builder::app_hub::ListServiceProjectAttachments::new(self.inner.clone())
    }

    /// Attaches a service project to the host project.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_service_project_attachment(
        &self,
    ) -> super::builder::app_hub::CreateServiceProjectAttachment {
        super::builder::app_hub::CreateServiceProjectAttachment::new(self.inner.clone())
    }

    /// Gets a service project attachment.
    pub fn get_service_project_attachment(
        &self,
    ) -> super::builder::app_hub::GetServiceProjectAttachment {
        super::builder::app_hub::GetServiceProjectAttachment::new(self.inner.clone())
    }

    /// Deletes a service project attachment.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_service_project_attachment(
        &self,
    ) -> super::builder::app_hub::DeleteServiceProjectAttachment {
        super::builder::app_hub::DeleteServiceProjectAttachment::new(self.inner.clone())
    }

    /// Detaches a service project from a host project.
    /// You can call this API from any service project without needing access to
    /// the host project that it is attached to.
    pub fn detach_service_project_attachment(
        &self,
    ) -> super::builder::app_hub::DetachServiceProjectAttachment {
        super::builder::app_hub::DetachServiceProjectAttachment::new(self.inner.clone())
    }

    /// Lists Discovered Services that can be added to an Application in a host
    /// project and location.
    pub fn list_discovered_services(&self) -> super::builder::app_hub::ListDiscoveredServices {
        super::builder::app_hub::ListDiscoveredServices::new(self.inner.clone())
    }

    /// Gets a Discovered Service in a host project and location.
    pub fn get_discovered_service(&self) -> super::builder::app_hub::GetDiscoveredService {
        super::builder::app_hub::GetDiscoveredService::new(self.inner.clone())
    }

    /// Lists a Discovered Service in a host project and location, with a
    /// given resource URI.
    pub fn lookup_discovered_service(&self) -> super::builder::app_hub::LookupDiscoveredService {
        super::builder::app_hub::LookupDiscoveredService::new(self.inner.clone())
    }

    /// Lists Services in an Application.
    pub fn list_services(&self) -> super::builder::app_hub::ListServices {
        super::builder::app_hub::ListServices::new(self.inner.clone())
    }

    /// Creates a Service in an Application.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_service(&self) -> super::builder::app_hub::CreateService {
        super::builder::app_hub::CreateService::new(self.inner.clone())
    }

    /// Gets a Service in an Application.
    pub fn get_service(&self) -> super::builder::app_hub::GetService {
        super::builder::app_hub::GetService::new(self.inner.clone())
    }

    /// Updates a Service in an Application.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_service(&self) -> super::builder::app_hub::UpdateService {
        super::builder::app_hub::UpdateService::new(self.inner.clone())
    }

    /// Deletes a Service from an Application.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_service(&self) -> super::builder::app_hub::DeleteService {
        super::builder::app_hub::DeleteService::new(self.inner.clone())
    }

    /// Lists Discovered Workloads that can be added to an Application in a host
    /// project and location.
    pub fn list_discovered_workloads(&self) -> super::builder::app_hub::ListDiscoveredWorkloads {
        super::builder::app_hub::ListDiscoveredWorkloads::new(self.inner.clone())
    }

    /// Gets a Discovered Workload in a host project and location.
    pub fn get_discovered_workload(&self) -> super::builder::app_hub::GetDiscoveredWorkload {
        super::builder::app_hub::GetDiscoveredWorkload::new(self.inner.clone())
    }

    /// Lists a Discovered Workload in a host project and location, with a
    /// given resource URI.
    pub fn lookup_discovered_workload(&self) -> super::builder::app_hub::LookupDiscoveredWorkload {
        super::builder::app_hub::LookupDiscoveredWorkload::new(self.inner.clone())
    }

    /// Lists Workloads in an Application.
    pub fn list_workloads(&self) -> super::builder::app_hub::ListWorkloads {
        super::builder::app_hub::ListWorkloads::new(self.inner.clone())
    }

    /// Creates a Workload in an Application.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_workload(&self) -> super::builder::app_hub::CreateWorkload {
        super::builder::app_hub::CreateWorkload::new(self.inner.clone())
    }

    /// Gets a Workload in an Application.
    pub fn get_workload(&self) -> super::builder::app_hub::GetWorkload {
        super::builder::app_hub::GetWorkload::new(self.inner.clone())
    }

    /// Updates a Workload in an Application.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_workload(&self) -> super::builder::app_hub::UpdateWorkload {
        super::builder::app_hub::UpdateWorkload::new(self.inner.clone())
    }

    /// Deletes a Workload from an Application.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_workload(&self) -> super::builder::app_hub::DeleteWorkload {
        super::builder::app_hub::DeleteWorkload::new(self.inner.clone())
    }

    /// Lists Applications in a host project and location.
    pub fn list_applications(&self) -> super::builder::app_hub::ListApplications {
        super::builder::app_hub::ListApplications::new(self.inner.clone())
    }

    /// Creates an Application in a host project and location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_application(&self) -> super::builder::app_hub::CreateApplication {
        super::builder::app_hub::CreateApplication::new(self.inner.clone())
    }

    /// Gets an Application in a host project and location.
    pub fn get_application(&self) -> super::builder::app_hub::GetApplication {
        super::builder::app_hub::GetApplication::new(self.inner.clone())
    }

    /// Updates an Application in a host project and location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_application(&self) -> super::builder::app_hub::UpdateApplication {
        super::builder::app_hub::UpdateApplication::new(self.inner.clone())
    }

    /// Deletes an Application in a host project and location.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn delete_application(&self) -> super::builder::app_hub::DeleteApplication {
        super::builder::app_hub::DeleteApplication::new(self.inner.clone())
    }

    /// Lists information about the supported locations for this service.
    pub fn list_locations(&self) -> super::builder::app_hub::ListLocations {
        super::builder::app_hub::ListLocations::new(self.inner.clone())
    }

    /// Gets information about a location.
    pub fn get_location(&self) -> super::builder::app_hub::GetLocation {
        super::builder::app_hub::GetLocation::new(self.inner.clone())
    }

    /// Sets the access control policy on the specified resource. Replaces
    /// any existing policy.
    ///
    /// Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED`
    /// errors.
    pub fn set_iam_policy(&self) -> super::builder::app_hub::SetIamPolicy {
        super::builder::app_hub::SetIamPolicy::new(self.inner.clone())
    }

    /// Gets the access control policy for a resource. Returns an empty policy
    /// if the resource exists and does not have a policy set.
    pub fn get_iam_policy(&self) -> super::builder::app_hub::GetIamPolicy {
        super::builder::app_hub::GetIamPolicy::new(self.inner.clone())
    }

    /// Returns permissions that a caller has on the specified resource. If the
    /// resource does not exist, this will return an empty set of
    /// permissions, not a `NOT_FOUND` error.
    ///
    /// Note: This operation is designed to be used for building
    /// permission-aware UIs and command-line tools, not for authorization
    /// checking. This operation may "fail open" without warning.
    pub fn test_iam_permissions(&self) -> super::builder::app_hub::TestIamPermissions {
        super::builder::app_hub::TestIamPermissions::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn list_operations(&self) -> super::builder::app_hub::ListOperations {
        super::builder::app_hub::ListOperations::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> super::builder::app_hub::GetOperation {
        super::builder::app_hub::GetOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn delete_operation(&self) -> super::builder::app_hub::DeleteOperation {
        super::builder::app_hub::DeleteOperation::new(self.inner.clone())
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn cancel_operation(&self) -> super::builder::app_hub::CancelOperation {
        super::builder::app_hub::CancelOperation::new(self.inner.clone())
    }
}
